/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.psdk.local;

import android.content.ComponentName;
import android.content.Context;
import android.content.ServiceConnection;
import android.os.IBinder;
import com.qihoo.psdk.k;
import com.qihoo.psdk.remote.b;
import com.qihoo.psdk.util.h;

public class c implements ServiceConnection {
    private static com.qihoo.psdk.remote.a a = null;
    private static Context b = null;
    private boolean c = false;
    private static boolean d = false;
    private static String e = "";
    private static int f = 0;
    private static String g = "";
    private static String h = "";
    private static String i = "";
    private static c j = null;
    private static long k = 0L;
    private static boolean l = true;
    private static long m = 180000L;

    public c(Context paramContext) {
        b = paramContext;
        this.c = false;
        d = false;
        j = this;
    }

    private boolean o() {
        return this.c;
    }

    public void onServiceConnected(ComponentName paramComponentName, IBinder paramIBinder) {
        try {
            a = b.a(paramIBinder);
            this.c = true;
            e = com.qihoo.psdk.util.a.a(b, "QHOPENSDK_APPID");
            try {
                f = (int) (Long.parseLong(e) % 1000L);
            } catch (Exception localException1) {
                h.a("QLocalSession", localException1);
            }
            g = com.qihoo.psdk.util.a.c(b);
            h = com.qihoo.psdk.util.a.a(b, e, g);
            i = com.qihoo.psdk.util.a.i(b);
            h.a("QLocalSession", "registerId: " + h + ", randDelay: " + f);
            q();
        } catch (Exception localException2) {
            h.a("QLocalSession", localException2);
        }
    }

    private void p() {
        try {
            h.b("QLocalSession", "Retry to bind remote service...");
            d = false;
            b.unbindService(this);
        } catch (Exception localException1) {
            h.a("QLocalSession", localException1);
        } catch (Error localError1) {
            h.a("QLocalSession", localError1);
        } finally {
            try {
                this.c = false;
                QLocalService.a(b, true);
            } catch (Exception localException4) {
                h.a("QLocalSession", localException4);
            } catch (Error localError4) {
                h.a("QLocalSession", localError4);
            }
        }
    }

    public void onServiceDisconnected(ComponentName paramComponentName) {
        try {
            h.b("QLocalSession", "onServiceDisconnected...");
            p();
        } catch (Exception localException) {
            h.a("QLocalSession", localException);
        }
    }

    private void q() {
        new d(this).start();
    }

    protected static void a() {
        new e().start();
    }

    private void r() {
        new f(this).start();
    }

    protected static void a(long paramLong) {
        m = paramLong;
    }

    protected static long b() {
        return (m / 60000L);
    }

    protected static String c() {
        String str = "";
        try {
            str = str + "register: " + a.a(e) + "\n";
            str = str + "registerId: " + h + "\n";
            str = str + "registerTime: " + a.b(e) + "\n";
            str = str + "environment: md.openapi.360.cn\n";
            str = str + "product: mgame\n";
            str = str + "server: " + a.b() + "\n";
            str = str + "release: " + (!(k.a)) + "\n";
            str = str + "version: 1.1.1.140807\n";
            str = str + "bindRemote: " + j.o() + "\n";
            str = str + "primary: " + a.a();
        } catch (Exception localException) {
            h.a("QLocalSession", localException);
        }
        return str;
    }
}